package com.example;
import java.util.Scanner;
public class Day2Geo2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.printf("Enter the coordinates, width and length for Rectangle1:");
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double width1 = sc.nextDouble();
        double length1 = sc.nextDouble();//矩阵1

        System.out.printf("Enter the coordinates, width and length for Rectangle2:");
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        double width2 = sc.nextDouble();
        double length2 = sc.nextDouble();//矩阵2

        double xDistance = x1 >= x2 ? x1 - x2 : x2 - x1;
        double yDistance = y1 >= y2 ? y1 - y2 : y2 - y1;

        if(xDistance <= (width1 - width2)/2 && yDistance <= (length1 - length2)){
            System.out.printf("Rectangle2 is inside Rectangle1");
        }
        else if(xDistance >= (width1 - width2)/2 && yDistance >= (length1 - length2)){
            System.out.printf("Rectangle2 overlaps Rectangle1");
        }
        else{
            System.out.printf("Rectangle2 does not overlap Rectangle1");
        }
    }
}
